<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>广告到期提醒</title>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery/jquery.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery/jquery-ui/jquery-ui.js"></script>

<script src="${pageContext.request.contextPath}/js/bootstrap/bootstrap.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/ui/table/bootstrap-table.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/ui/table/locale/bootstrap-table-zh-CN.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/ui/table/plugins/tableExport.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/ui/table/plugins/table-export.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/ui/table/plugins/jquery.base64.js" type="text/javascript"></script>

<script src="${pageContext.request.contextPath}/ui/layui/layui.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/ui/layui/lay/modules/laydate.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/ui/layui/lay/modules/layer.js" type="text/javascript"></script>
 <script src="${pageContext.request.contextPath}/ui/layui/lay/modules/form.js" type="text/javascript"></script>
 <link rel="stylesheet" href="${pageContext.request.contextPath}/ui/layui/css/modules/laydate/laydate.css" >
 <link rel="stylesheet" href="${pageContext.request.contextPath}/css/jquery-css/jquery-ui.css">
 <link rel="stylesheet" href="${pageContext.request.contextPath}/css/bootstrap-css/bootstrap.css">
<link rel="stylesheet" href="${pageContext.request.contextPath}/ui/table/bootstrap-table.css">
<link rel="stylesheet" href="${pageContext.request.contextPath}/ui/layui/css/layui.css" >
<link rel="stylesheet" href="${pageContext.request.contextPath}/ui/layui/css/global.css" >
<link rel="stylesheet" href="${pageContext.request.contextPath}/ui/layui/css/modules/layer/default/layer.css" >
 <link rel="stylesheet" href="${pageContext.request.contextPath}/ui/layui/css/modules/code.css" >


 <style>
  .container{
   	width:95%;
   	
  }
  
  .modal-industry{
  	width:900px;
  }
  .modal-body{
    max-height:750px;
  }
   .modal-body-industry{
  	height:450px;
  }
    
 </style>

</head>
<body>
<%@include file="/webpage/frame/top.jsp" %>
<div class="container">	
	<div id="modal" class="modal-industry modal fade" style="display:none">
		<div class="modal-dialog">
			<div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title"></h4>
                    <span class='alert_input'></span>
                </div>
                <div class="modal-body-industry modal-body">
                    <div class="form-group">
                        <label>客户公司名称</label>
                        <input type="text" class="form-control" name="companyName" style="width:400px" readonly="readonly"/>
                    </div>                
                    <div class="form-group">
                        <label>网站域名</label>
                        <textarea placeholder="" class="layui-textarea" name="domain" readonly="readonly"></textarea>
                    </div>
                    <div class="form-group">
                        <label>是否赠送wap站</label>
                        <select name="ifGiveWap"  class="form-control" readonly="readonly">
                       		<option value="是">是</option>
                       		<option value="否">否</option>
                        </select>                     
                    </div>
                    <div class="form-group">
                        <label>广告上线时间</label>
                        <input type="text" class="form-control" name="adOnlineDate" lay-verify="date" id="adOnlineDate" placeholder="广告上线时间" readonly="readonly">                       
                    </div>
                    <div class="form-group">
                        <label>广告到期时间</label>
                        <input type="text" class="form-control" name="adOfflineDate" lay-verify="date" id="adOfflineDate" placeholder="广告到期时间" readonly="readonly">                       
                    </div>  
                    <div class="form-group">
                        <label>合同-备注</label>
                        <textarea placeholder="" class="layui-textarea" name="contractRemark" readonly="readonly"></textarea>
                    </div>                    
                    <div class="form-group">
                        <label>维护公司名称</label>
                        <input type="text" class="form-control" name="siteCompany" readonly="readonly" placeholder="">                       
                    </div>
                    <div class="form-group">
                        <label>维护公司联系电话</label>
                        <input type="text" class="form-control" name="scPhone" readonly="readonly" placeholder="">                       
                    </div>
                    <div class="form-group">
                        <label>维护公司联系qq</label>
                        <input type="text" class="form-control" name="scQq" readonly="readonly" placeholder="">                       
                    </div>
                    <div class="form-group">
                        <label>易数宝代码安装-备注</label>
                        <textarea placeholder="" class="layui-textarea" name="scRemark" readonly="readonly"></textarea>
                    </div>
				</div>			
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <!-- <button type="button" class="btn btn-primary submit">提交</button> -->
                </div>				
			</div>
		</div>	
	</div>

	<p class="toolbar">
          <!-- <button type="button" class="export-excel btn btn-primary btn-xs" data-table="#contracttable">导出Excel</button> -->
          <span class="alert"></span>
       </p>
        	
	<table id="contracttable"  data-show-refresh="true"
              data-search="true"
              data-click-to-select="true"
              data-show-export="true"
              data-query-params="queryParams"             
              data-pagination="true"
		   	  data-toolbar=".toolbar"
              data-sort-name="adOfflineDate" 
              data-sort-order="asc" 		   	  	
		   	  data-show-columns="true"	   
              >
           <thead>
           <tr>
            <th data-field="state" data-radio="true"></th>
           	<th data-field="id" data-show="true" data-visible="false">id</th>
            <th data-field="companyName">客户公司名称</th>
   			<th data-field="adOfflineDate">广告到期时间</th>
   			<th data-field="adOnlineDate">广告上线时间</th>
            <th data-field="companyStateValue">续费状态</th>
            <th data-field="employeeName" data-visible="true">客服分配</th> 
            <th data-field="employeeNum" data-visible="true">客服工号</th>             
            <th data-field="industryName">所属行业</th>
   			<th data-field="channeName">推广平台</th>            
            <th data-field="customerName">客户姓名</th>
            <th data-field="phone">客户联系电话</th>
 			<th data-field="signDate">签约时间</th>
   			<th data-field="expireDate">合约到期时间</th>
   			<th data-field="serviceCycle">服务周期</th>
   			<th data-field="servicePrice">服务费用</th>
   			<th data-field="contractRemark" data-visible="false">合同备注</th>
            <th data-field="salesName">销售名称</th>
            <th data-field="salesDepartment">销售部门</th>
            <th data-field="domain" data-visible="false">网站域名</th>
            <th data-field="isInstalledBridge">是否安装代码</th>
            <th data-field="ifGiveWap">是否赠送wap站</th>
            <th data-field="siteCompany" data-visible="false">维护公司名称</th>
            <th data-field="scPhone" data-visible="false">维护公司联系电话</th>
            <th data-field="scQq" data-visible="false">维护公司联系qq</th>         
            <th data-field="scRemark" data-visible="false">代码安装-备注</th>         
                     
            <th data-field="action"
                data-align="center"
                data-formatter="actionFormatter"
                data-events="actionEvents">操作</th>
           </tr>
           </thead>
		
	</table>

</div>

<!-- 日期选择代码  -->
<script>
layui.use('laydate', function(){
  var laydate = layui.laydate;
  var allTime = {
     min: '1970-01-01 23:59:59'
    ,max: '2099-06-16 23:59:59'
    ,istoday: true
    
  };
  document.getElementById('adOnlineDate').onclick = function(){
	allTime.elem = this
    laydate(allTime);
  }
  document.getElementById('adOfflineDate').onclick = function(){
	allTime.elem = this
    laydate(allTime);
  }
  
});
</script>	
<script type="text/javascript">
	//初始化，加载合同-广告信息列表
	var API_URL = '${pageContext.request.contextPath}/contractInfoController.do?getAdOfflineInfoBySemUserId';	
	var $table = $('#contracttable').bootstrapTable(
			{
				url: API_URL,
				pageSize:25,
				pageList : [15, 25, 100, 500],
				height: getHeight()
			}),     
	   $modal = $('#modal').modal({show: false}),
	   $alert = $('.alert').hide(),
	   $alert_input = $('.alert_input').hide();

	//获取相对的固定高度
   function getHeight() {
        return $(window).height()-200;
    }
	
    function actionFormatter(value,row, index) {        
    	buttonArray =  new Array();
    	buttonArray[0]='<a class="update btn btn-default" href="javascript:" title="查看合同-广告">查看</a>';   	
        return buttonArray.join(' ');
    }

    window.actionEvents = {
            'click .update': function (e, value, row) {
            	showModal_update($(this).attr('title'), row);
            }    
    }

    //弹出窗口-查看
    function showModal_update(title, row) { 
        $modal.data('id', row.id);
        $modal.find('.modal-title').text(title);
        
        for (var name in row) {
            $modal.find('input[name="' + name + '"]').val(row[name]);
            $modal.find('textarea[name="' + name + '"]').val(row[name]);
            $modal.find('select[name="' + name + '"]').find("option[value='"+row[name]+"']").attr("selected",true);
        }   
		
    	$modal.modal('show');
    }
    
    $(function () {
/* 	   	 TableExport.init();
	 	//导出按钮
	 	$('#export').click(function () {
	 		
	 	  	$table.tableExport({
	 	      type: 'excel',
	 	      escape: false
	 	    });
	 	  }); */
 	
/* 	 	 $modal.find('.submit').click(function () {
	        	var submitPath = '${pageContext.request.contextPath}/contractInfoController.do?updateContractInfo';
	        	
	            var row = {};
				
	            if($modal.data('id')){
	            	row['id']=$modal.data('id')
	            }
	            $modal.find('input[name]').each(function () {          	
	                row[$(this).attr('name')] = $(this).val();
	            });
	            $modal.find('select[name]').each(function(){
	            	row[$(this).attr('name')]	= $(this).val();
	            });
	            $modal.find('textarea[name]').each(function(){
	            	row[$(this).attr('name')]	= $(this).val();
	            });
	            
	            console.log(row);
	            
	            setTimeout(function(){
	            	$.ajax({
	                    url: submitPath,
	                    type: 'post',
	                    contentType: 'application/json',
	                    data: JSON.stringify(row),
	                    success: function (data,status) {
	                        $modal.modal('hide');
	                        result = JSON.parse(data);
	                        
	                        if(result.success){
	                        	 $table.bootstrapTable('refresh');
	                        	 showAlert(result.msg, 'success');
	                        }else{
	                        	 showAlert(result.msg, 'danger');
	                        }
	                    },
	                    error: function () {
	                        $modal.modal('hide');
	                        showAlert(($modal.data('id') ? '更新' : '新建') + '失败异常', 'danger');
	                    }
	                });
	            },1000); 	
    	
	 	 }); */
    });

    function showAlert(title, type) {
        $alert.attr('class', 'alert alert-' + type || 'success')
              .html('<i class="glyphicon glyphicon-check"></i> ' + title).show();
        setTimeout(function () {
            $alert.hide();
        }, 3000);
    }    
    
</script>


<%@include file="/webpage/frame/bottom.jsp" %>
</body>
</html>